<?php
	require_once "../includes/class/member_management.class.php";
    require_once '../includes/class.phpmailer.php';

	$ref_id = $_GET['editref'];	
	
	if(isset($_POST['editCode']))
	{
					
					$sqlUpd = "UPDATE tb1_referral_code SET ref_code='".addslashes($_POST['ReferralCode'])."'  where ref_id='$ref_id'";
					$rstUpd = mysql_query($sqlUpd);

		if($rstUpd) { $msg = "Referral code updated successfully."; }
		else { $msg=""; }					
		//header("location: index.php?index.php?editref=".$ref_id."&msg=1");
	}
	
    $sqlSelUsr="SELECT * FROM tb1_referral_code WHERE ref_id='$ref_id'";
    $rstSelUsr=mysql_query($sqlSelUsr);
    $rowEmailuser=mysql_fetch_array($rstSelUsr);
?>

<table width="100%" border="1" cellspacing="0" class='container'>
  <tr>
  	<td height="26" class="tdHeader">Referral Code</td>
  </tr>
  <tr>
    <td>
		
		<table width="100%" border="0" class="content">
		  <tr  class="content">
			<td height="32" colspan="3"><div id="messageArea"><?php if(isset($msg))
			echo "<font color='#0000FF'><b>".$msg."</b></font>";
			?></div></td>
			</tr>
            <form enctype="multipart/form-data" name="frmEditProfile" method="post" action="<?php echo $_SERVER['php_self']?>">
		  <tr>
            <td  height="10"></td>
		    <td></td>
		    <td></td>
		    </tr>
		  <tr>
            <td colspan="2"><div id="lblSecretQuestion">Referral Code</div>
                 <input type="text" name="ReferralCode" id="ReferralCode" value="<?php echo stripslashes($rowEmailuser['ref_code']) ?>"> 
		    <td>
		  <tr>
			<td  height="10"></td>
			<td></td>
			<td></td>
		  </tr>		
		  <tr>
			<td><input type="submit" name="editCode" id="editCode" value="Update" />&nbsp;&nbsp;<a href="index.php?ref_code">Back To List</a></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		  </tr>		
          </form>
		</table>
	  
	</td>
  </tr>
</table>  
